package com.jason.library.immersion.model

import android.graphics.Color
import android.nfc.tech.NfcBarcode

/**
 * Description:BarParams
 *
 * @author chenbaoyang
 * @create 2021/1/11 16:00
 */
data class BarParams(
    /**
     * 是否忽略状态栏或导航栏的占位高度（相当于 [android.view.View.setFitsSystemWindows]）
     * true  : contentView 位于状态栏和导航栏之间（不占用状态栏和导航栏位置）
     * false : contentView 可以伸到状态栏和导航栏的位置（沉浸式）
     */
    internal var fitWindow: Boolean = false,

    /**
     * 状态栏颜色
     */
    internal var statusBarColor: Int = 0,

    /**
     * 状态栏和导航栏背景
     */
    internal var resId : Int = 0,

    /**
     * 导航栏颜色
     */
    internal var navigationBarColor: Int = 0,

    /**
     * 透明状态栏，不写默认透明色
     */
    internal var transparentStatusBarEnable: Boolean = false,

    /**
     * 透明导航栏，不写默认黑色
     */
    internal var transparentNavigationBarEnable: Boolean = false
) {

    companion object {
        fun newInstance(): BarParams =
            BarParams().apply {
                fitWindow = true
                statusBarColor = Int.MIN_VALUE
                resId = -1;
                navigationBarColor = Int.MIN_VALUE
                transparentStatusBarEnable = false
                transparentNavigationBarEnable = false
            }

    }

    /**
     * 设置是否忽略状态栏或导航栏的占位高度
     */
    fun fitWindow(fitWindow: Boolean): BarParams = apply { this.fitWindow = fitWindow }

    /**
     * 是否透明状态栏
     */
    fun transparentStatusBar(transparentStatusBarEnable: Boolean): BarParams =
        apply {
            this.transparentStatusBarEnable = transparentStatusBarEnable
            this.statusBarColor = Color.TRANSPARENT
        }

    /**
     * 是否透明导航栏
     */
    fun transparentNavigationBar(transparentNavigationBarEnable: Boolean) : BarParams =
        apply {
            this.transparentNavigationBarEnable = transparentNavigationBarEnable
            this.navigationBarColor = Color.TRANSPARENT
        }

    /**
     * 设置状态栏颜色
     */
    fun statusBarColor(statusBarColor: Int) : BarParams =
        apply {
            this.statusBarColor = statusBarColor
            this.transparentStatusBarEnable = false
        }

    /**
     * 设置导航栏颜色
     */
    fun navigationBarColor(navigationBarColor : Int) : BarParams =
        apply {
            this.navigationBarColor = navigationBarColor
            this.transparentNavigationBarEnable = false
        }

    fun drawableBar(resId: Int) : BarParams =
        apply {
            this.resId = resId
            this.transparentStatusBarEnable = false
            this.transparentNavigationBarEnable = false
        }

}